package com.ce.cetag.tags.validpanel;


import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;

/**
*
* <p>版权所有：中企动力
* <p>未经本公司许可，不得以任何方式复制或使用本程序任何部分
* <p>功能描述：权限面板标签
*
* @author kuanglingxuan
* Created on 2007-8-31
*/
public class ValidPanelTag extends TagSupport {

	public int doStartTag() throws JspTagException{

		String pageName = ((HttpServletRequest)pageContext.getRequest()).getServletPath();
		pageName = pageName.substring(pageName.lastIndexOf("/")+1);
		System.out.println("pageName------>"+pageName);
		String valiCode = pageName + "_" + getFunction();

		if(getValidCodes() != null && this.getValidCodes().contains(valiCode))
			return EVAL_BODY_INCLUDE;
		else
			return SKIP_BODY;

	  }


	public int doEndTag() throws JspTagException{

		return EVAL_PAGE;

	}

	private List<String> validCodes;
	private String function;

	public String getFunction() {
		return function;
	}


	public void setFunction(String function) {
		this.function = function;
	}


	public List<String> getValidCodes() {
		return validCodes;
	}


	public void setValidCodes(List<String> validCodes) {
		this.validCodes = validCodes;
	}

	public void release(){
//		System.out.println("in release()");
		super.release();
		this.validCodes = null;
		this.function = null;
	}

}
